<template>
  <div class="pingtai">
    <h2>平台实时交易情况</h2>
    <ul>
      <li>
        <p>平台资金总额</p>
        <h3>{{ totalsale }}元</h3>
      </li>
      <li>
        <p>今日交易总额</p>
        <h3>{{ todaysale }}元</h3>
      </li>
      <li>
        <p>订单成交数量</p>
        <h3>{{ totalcount }}单</h3>
      </li>
    </ul>
  </div>
</template>

<script>
import { orderAll } from "../../api/hjn/index.js";
export default {
  data() {
    return {
      arr: [],
    };
  },
  computed: {
    totalsale() {
      let sum = 0;
      for (var v of this.arr) {
        sum += v.oriprice * v.bnum;
      }
      return sum;
    },
    todaysale() {
      var sum1 = 0;
      for (var v of this.arr) {
        if (v.createtime === "2022-12-15T16:00:00.000+00:00") {
          sum1 += v.oriprice * v.bnum;
        }
      }
      return sum1;
    },
    totalcount() {
      var sum2 = 0;
      for (var v of this.arr) {
        sum2 += v.bnum;
      }
      return sum2;
    },
  },
  mounted() {
    orderAll(1, 100).then((ok) => {
      console.log(ok.data.records);
      this.arr = ok.data.records;
    });
  },
};
</script>

<style scoped>
.pingtai {
  /* height: 100px; */
  padding-left: 6%;
  margin-top: 40px;
}
h2 {
  width: 70%;
  border-bottom: 1px solid #eee;
  font-size: 16px;
  height: 24px;
  line-height: 24px;
  padding-bottom: 20px;
  margin-bottom: 20px;
}
ul {
  display: flex;
}
li {
  margin-right: 100px;
  height: 100px;
  color: #aaa;
  font-size: 16px;
}
h3 {
  margin: 16px 0 0 10px;
  color: #000000d8;
  font-size: 24px;
  font-weight: 400;
}
</style>